<template>
  <div class="social-signup-container">
    <div v-show="visiable" class="sign-btn" @click="gitlabHandleClick('gitlab')">
      <span class="gitlab-svg-container"><svg-icon icon-class="gitlab" class="icon" /></span>
    </div>
  </div>
</template>

<script>
// import openWindow from '@neu/biz-core/utils/open-window'
import { getOAuth2Config } from '@neu/biz-core/api/user'

export default {
  name: 'SocialSignin',
  data() {
    return {
      oauth2Config: {}
    }
  },
  computed: {
    visiable: function() {
      return !!this.oauth2Config.baseUrl
    }
  },
  created() {
    getOAuth2Config().then(response => {
      this.oauth2Config = response.data || {}
    })
  },
  methods: {
    gitlabHandleClick(thirdpart) {
      const client_id = this.oauth2Config.clientId
      const redirect_uri = this.oauth2Config.redirectUrl
      const url = this.oauth2Config.baseUrl + this.oauth2Config.authorizeUri + '?client_id=' + client_id + '&redirect_uri=' + redirect_uri + '&response_type=code'
      window.location.href = url
    }
  }
}
</script>

<style lang="scss" scoped>
  .social-signup-container {
    margin: 0 0;
    .sign-btn {
      display: inline-block;
      cursor: pointer;
      color: #fff;
    }
    .icon {
      color: #fff;
      font-size: 24px;
    }
    .gitlab-svg-container {
      display: inline-block;
      width: 40px;
      height: 40px;
      line-height: 40px;
      text-align: center;
      padding-top: 1px;
      border-radius: 4px;
    }
  }
</style>
